import Vue from 'vue';
import VueRouter from 'vue-router';
import index from '../views/index.vue';
import login from '../views/login.vue';
import forgot from '../views/forgot.vue';
import register from '../views/register.vue';
Vue.use(VueRouter)

const routes = [
    // 主页
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            index: 0,
            title: '首页'
        }
    },

    // 登录
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: {
            index: 0,
            title: '登录'
        }
    },

            // 注册
        {
            path: '/register',
            name: 'register',
            component: register,
            meta: {
                index: 0,
                title: '注册'
            }
        },
    	
	
    // 忘记密码
    {
        path: '/forgot',
        name: "forgot",
        component: forgot,
        meta: {
            index: 0,
            title: '忘记密码'
        }
    },

    // 修改密码
    {
        path: '/user/password',
        name: "password",
        component: () => import("../views/user/password.vue"),
        meta: {
            index: 0,
            title: '修改密码'
        }
    },

    // 视频播放页
    {
        path: "/media/video",
        name: "video",
        component: () => import('../views/media/video.vue'),
        meta: {
            index: 0,
            title: "视频"
        }
    },

    // 音频播放页
    {
        path: "/media/audio",
        name: "audio",
        component: () => import('../views/media/audio.vue'),
        meta: {
            index: 0,
            title: "音频"
        }
    },

            // 权限路由
        {
            path: '/auth/table',
            name: 'auth_table',
            component: () => import('../views/auth/table.vue'),
            meta: {
                index: 0,
                title: '权限列表'
            }
        },
        {
            path: '/auth/view',
            name: 'auth_view',
            component: () => import('../views/auth/view.vue'),
            meta: {
                index: 0,
                title: '权限详情'
            }
        },
    
    
    
    
            	    
        	            // 项目经理路由
        {
            path: '/developers/table',
            name: 'developers_table',
            component: () => import('../views/developers/table.vue'),
            meta: {
                index: 0,
                title: '项目经理列表'
            }
        },
        {
            path: '/developers/view',
            name: 'developers_view',
            component: () => import('../views/developers/view.vue'),
            meta: {
                index: 0,
                title: '项目经理详情'
            }
        },
						            // 开发用户路由
        {
            path: '/develop_users/table',
            name: 'develop_users_table',
            component: () => import('../views/develop_users/table.vue'),
            meta: {
                index: 0,
                title: '开发用户列表'
            }
        },
        {
            path: '/develop_users/view',
            name: 'develop_users_view',
            component: () => import('../views/develop_users/view.vue'),
            meta: {
                index: 0,
                title: '开发用户详情'
            }
        },
						            // 测试用户路由
        {
            path: '/test_user/table',
            name: 'test_user_table',
            component: () => import('../views/test_user/table.vue'),
            meta: {
                index: 0,
                title: '测试用户列表'
            }
        },
        {
            path: '/test_user/view',
            name: 'test_user_view',
            component: () => import('../views/test_user/view.vue'),
            meta: {
                index: 0,
                title: '测试用户详情'
            }
        },
						            // 项目类型路由
        {
            path: '/project_type/table',
            name: 'project_type_table',
            component: () => import('../views/project_type/table.vue'),
            meta: {
                index: 0,
                title: '项目类型列表'
            }
        },
        {
            path: '/project_type/view',
            name: 'project_type_view',
            component: () => import('../views/project_type/view.vue'),
            meta: {
                index: 0,
                title: '项目类型详情'
            }
        },
						            // 项目信息路由
        {
            path: '/change_notice/table',
            name: 'change_notice_table',
            component: () => import('../views/change_notice/table.vue'),
            meta: {
                index: 0,
                title: '项目信息列表'
            }
        },
        {
            path: '/change_notice/view',
            name: 'change_notice_view',
            component: () => import('../views/change_notice/view.vue'),
            meta: {
                index: 0,
                title: '项目信息详情'
            }
        },
						            // 项目团队路由
        {
            path: '/project_team/table',
            name: 'project_team_table',
            component: () => import('../views/project_team/table.vue'),
            meta: {
                index: 0,
                title: '项目团队列表'
            }
        },
        {
            path: '/project_team/view',
            name: 'project_team_view',
            component: () => import('../views/project_team/view.vue'),
            meta: {
                index: 0,
                title: '项目团队详情'
            }
        },
						            // 风险登记路由
        {
            path: '/risk_registration/table',
            name: 'risk_registration_table',
            component: () => import('../views/risk_registration/table.vue'),
            meta: {
                index: 0,
                title: '风险登记列表'
            }
        },
        {
            path: '/risk_registration/view',
            name: 'risk_registration_view',
            component: () => import('../views/risk_registration/view.vue'),
            meta: {
                index: 0,
                title: '风险登记详情'
            }
        },
						            // 变更记录路由
        {
            path: '/change_record/table',
            name: 'change_record_table',
            component: () => import('../views/change_record/table.vue'),
            meta: {
                index: 0,
                title: '变更记录列表'
            }
        },
        {
            path: '/change_record/view',
            name: 'change_record_view',
            component: () => import('../views/change_record/view.vue'),
            meta: {
                index: 0,
                title: '变更记录详情'
            }
        },
						            // 删除申请路由
        {
            path: '/delete_application/table',
            name: 'delete_application_table',
            component: () => import('../views/delete_application/table.vue'),
            meta: {
                index: 0,
                title: '删除申请列表'
            }
        },
        {
            path: '/delete_application/view',
            name: 'delete_application_view',
            component: () => import('../views/delete_application/view.vue'),
            meta: {
                index: 0,
                title: '删除申请详情'
            }
        },
						            // 项目测试路由
        {
            path: '/project_testing/table',
            name: 'project_testing_table',
            component: () => import('../views/project_testing/table.vue'),
            meta: {
                index: 0,
                title: '项目测试列表'
            }
        },
        {
            path: '/project_testing/view',
            name: 'project_testing_view',
            component: () => import('../views/project_testing/view.vue'),
            meta: {
                index: 0,
                title: '项目测试详情'
            }
        },
						            // 成本报告路由
        {
            path: '/cost_report/table',
            name: 'cost_report_table',
            component: () => import('../views/cost_report/table.vue'),
            meta: {
                index: 0,
                title: '成本报告列表'
            }
        },
        {
            path: '/cost_report/view',
            name: 'cost_report_view',
            component: () => import('../views/cost_report/view.vue'),
            meta: {
                index: 0,
                title: '成本报告详情'
            }
        },
						            // 任务类型路由
        {
            path: '/task_type/table',
            name: 'task_type_table',
            component: () => import('../views/task_type/table.vue'),
            meta: {
                index: 0,
                title: '任务类型列表'
            }
        },
        {
            path: '/task_type/view',
            name: 'task_type_view',
            component: () => import('../views/task_type/view.vue'),
            meta: {
                index: 0,
                title: '任务类型详情'
            }
        },
						            // 任务分配路由
        {
            path: '/task_allocation/table',
            name: 'task_allocation_table',
            component: () => import('../views/task_allocation/table.vue'),
            meta: {
                index: 0,
                title: '任务分配列表'
            }
        },
        {
            path: '/task_allocation/view',
            name: 'task_allocation_view',
            component: () => import('../views/task_allocation/view.vue'),
            meta: {
                index: 0,
                title: '任务分配详情'
            }
        },
						            // 消息推送路由
        {
            path: '/message_push/table',
            name: 'message_push_table',
            component: () => import('../views/message_push/table.vue'),
            meta: {
                index: 0,
                title: '消息推送列表'
            }
        },
        {
            path: '/message_push/view',
            name: 'message_push_view',
            component: () => import('../views/message_push/view.vue'),
            meta: {
                index: 0,
                title: '消息推送详情'
            }
        },
						    			// 操作日志路由
		{
		    path: '/operation_log/table',
		    name: 'operation_log_table',
		    component: () => import('../views/operation_log/table.vue'),
		    meta: {
		        index: 0,
		        title: '操作日志'
		    }
		},
	    // 用户路由
    {
        path: '/user/table',
        name: 'user_table',
        component: () => import('../views/user/table.vue'),
        meta: {
            index: 0,
            title: '用户列表'
        }
    },
    {
        path: '/user/view',
        name: 'user_view',
        component: () => import('../views/user/view.vue'),
        meta: {
            index: 0,
            title: '用户详情'
        }
    },
    {
        path: '/user/info',
        name: 'user_info',
        component: () => import('../views/user/info.vue'),
        meta: {
            index: 0,
            title: '个人信息'
        }
    },
    // 用户组路由
    {
        path: '/user_group/table',
        name: 'user_group_table',
        component: () => import('../views/user_group/table.vue'),
        meta: {
            index: 0,
            title: '用户组列表'
        }
    },
    {
        path: '/user_group/view',
        name: 'user_group_view',
        component: () => import('../views/user_group/view.vue'),
        meta: {
            index: 0,
            title: '用户组详情'
        }
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    let token = to.query.token;
    if (token) {
        $.db.set("token", token, 120);
    }
    next();
})

router.afterEach((to, from, next) => {
    let title = "软件企业项目管理系统-admin";
    document.title = title;
})

export default router
